package com.qupeng.demo.kafka.kafkaspringbootstreams.dashboard.model;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.HashSet;
import java.util.Set;

@Data
@NoArgsConstructor
@AllArgsConstructor
public class AgentSummary {
    private String agentId;
    private String agentName;
    private Integer configuredCapacity;
    private Set<String> caseHandled = new HashSet<>();
    private Set<String> caseHandling = new HashSet<>();
    private String status;
    private Integer statusDuration = 0;

    public AgentSummary(AgentProfile agentProfile) {
        this.agentId = agentProfile.getId();
        this.agentName = agentProfile.getName();
        this.configuredCapacity = agentProfile.getConfiguredCapacity();
    }

    public AgentSummary updateCaseInfo(AgentCase agentCase) {
        switch (agentCase.getStatus()) {
            case "HANDLING":
                caseHandling.add(agentCase.getId());
                break;
            case "CLOSED":
                caseHandled.add(agentCase.getId());
                break;
            default:
        }

        return this;
    }

    public AgentSummary updatePresence(AgentPresence agentPresence) {
        this.status = agentPresence.getStatus();
        this.statusDuration = agentPresence.getStatusDuration();
        return this;
    }
}
